package cn.wolfcode.wolf2w.business.service.impl;


import cn.wolfcode.wolf2w.business.api.domain.UserinfoEs;
import cn.wolfcode.wolf2w.business.repository.UserinfoEsRepository;
import cn.wolfcode.wolf2w.business.service.IUserinfoEsService;
import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.member.api.RemoteUserInfoService;
import cn.wolfcode.wolf2w.member.api.domain.UserInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserinfoEsServiceImpl implements IUserinfoEsService {

    @Autowired
    private UserinfoEsRepository repository;

    @Autowired
    private RemoteUserInfoService remoteUserinfoService;

    @Override
    public void initUserinfoEs() {
        //发送请求到攻略服务器请求攻略数据
        R<List<UserInfo>> r = remoteUserinfoService.list("inner");
        List<UserInfo> userinfoList = r.getData();
        for (UserInfo userinfo : userinfoList) {
            UserinfoEs es = new UserinfoEs();
            //属性拷贝 把同名属性拷贝到新对象中
            BeanUtils.copyProperties(userinfo,es);
            repository.save(es);
        }
        //将攻略数据转换为Es数据的类型

        //存储到Es库中
    }
}
